// TCP连接地址
package main

import (
    "os"
    "fmt"
    "net"
)

func main() {
    if len(os.Args) != 3 {
        fmt.Fprintf(os.Stderr, "Usage: %s networkType addr \n", os.Args[0])
        os.Exit(1)
    }
    networkType := os.Args[1]
    addr := os.Args[2]
    tcpAddr, err := net.ResolveTCPAddr(networkType, addr)
    if err != nil {
        fmt.Println("ResolveTCPAddr error: ", err.Error())
        os.Exit(1)
    }
    fmt.Println("The network type is: ", tcpAddr.Network())
    fmt.Println("The IP address is", tcpAddr.String())
}
